<!-- templates/progress_tracking/project_list.html -->
{% extends "base.html" %}
{% block content %}
<div class="container mt-4">
    <h2>项目追踪列表</h2>
      <form method="get" class="mb-3">
        <div class="row g-2 align-items-center">
            <div class="col-auto">
                <label for="id_title_query" class="visually-hidden">项目名称</label>
                <input type="text" name="title" id="id_title_query" value="{{ query_title }}" class="form-control" placeholder="项目名称">
            </div>
            <div class="col-auto">
                <select name="completed" class="form-select">
                    <option value="">全部</option>
                    <option value="True" {% if query_completed == 'True' %}selected{% endif %}>已完成</option>
                    <option value="False" {% if query_completed == 'False' %}selected{% endif %}>进行中</option>
                </select>
            </div>
            <div class="col-auto">
                <button type="submit" class="btn btn-primary">搜索</button>
            </div>
        </div>
    </form>
    <a href="{% url 'project_create' %}" class="btn btn-primary mb-3">新增项目</a>
    <a href="{% url 'export_projects_csv' %}" class="btn btn-success mb-3">导出报表</a>
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <th>项目名称</th>
                <th>开始日期</th>
                <th>截止日期</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for project in projects %}
            <tr>
                <td>{{ project.title }}</td>
                <td>{{ project.start_date|date:"Y-m-d" }}</td>
                <td>{{ project.end_date|date:"Y-m-d" }}</td>
                <td>{% if project.completed %}已完成{% else %}进行中{% endif %}</td>
                <td>
                    <a href="{% url 'project_update' project.pk %}" class="btn btn-sm btn-warning">编辑</a>
                    <a href="{% url 'project_delete' project.pk %}" class="btn btn-sm btn-danger">删除</a>
                    <a href="{% url 'set_deadline' project.pk %}" class="btn btn-sm btn-info">设置截止时间</a>
                    <a href="{% url 'extend_deadline' project.pk %}" class="btn btn-sm btn-info">延长截止时间</a>
                </td>
            </tr>
            {% empty %}
            <tr><td colspan="5" class="text-center">暂无项目</td></tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}

